/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package robocode.rescue.features;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.neuroph.core.NeuralNetwork;

/**
 *
 * @author guilh_000
 */
public class RedeNeuralFunctions {
    private NeuralNetwork network;
    private InputStream is;
    private File file;

    public RedeNeuralFunctions() {
        file = new File("C:\\rna\\redeNeural_4_desvio.nnet");
        
        try {
            is = new FileInputStream(file);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(RedeNeuralFunctions.class.getName()).log(Level.SEVERE, null, ex);
        }
        network = NeuralNetwork.load(is);
    }
    
    public double getNeuralAngleDesvio(double... input){
        network.setInput(input);
        network.calculate();
        double[] output = network.getOutput();
        Double answer = (Double) output[0];
        System.out.println("RNA angulo: "+answer+" >> "+answer*100+"º ");
        Movimentacao mv = new Movimentacao();
        
        return mv.anguloRNA(answer*100);
    }   
}
